//
//  CGQshebeiInfoCell.swift
//  SheYangBigData
//
//  Created by 叁拾叁 on 2021/4/8.
//  Copyright © 2021 叁拾叁. All rights reserved.
//


import UIKit


class CGQshebeiInfoCell: SYBaseCell {

    
    let title: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x333333)
        v.font = 14.autoBoldFontSize()
        v.text = "设备离线"
        return v
    }()
    
    let content: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x666666)
        v.font = 15.autoFontSize()
        v.text = "设备离线"
        return v
    }()
    
    var sepView: UIView = {
        let v = UIView()
        v.backgroundColor = Constant.bgViewColor
        return v
    }()
    
    var bgView: UIView = {
        let v = UIView()
        v.backgroundColor = .white
        v.layer.masksToBounds = true
        v.layer.cornerRadius = 5.autoWidth()
        return v
    }()
    public func configureView(model: CGQshebeiinfoModel, row: Int) {
//        title.text = model.name
//        if let p = model.imgPath {
//            pic.kf.setImage(with: URL(string: IMGIP+p))
//        }
        switch row {
        case 0:
            title.text = "所属项目"
            content.text = model.appName
            content.numberOfLines = 0
            break
        case 1:
            title.text = "采集端口"
            content.text = model.portName
            
            break
        case 2:
            title.text = "解析协议"
            content.text = model.protocolName
//            self.backgroundColor = UIColor(hex: 0xf0f0f0)
            break
        case 3:
            title.text = "设备类型"
            content.text = model.protocolDeviceTypeName
            
            break
        case 4:
            title.text = "设备编号"
            content.text = model.deviceId
            
            break
        case 5:
            title.text = "设备名称"
            content.text = model.deviceName
            
            break
        case 6:
            if model.isOnline == 1 {
                content.text = "在线"
                content.textColor = UIColor(hex: 0x08CC81)
                
            }else {
                content.text = "离线"
                content.textColor = UIColor(hex: 0xDE5D5C)


            }
            title.text = "状态"
            
            
            break
        case 7:
            title.text = "设备位置"
            content.text = model.deviceLocation
            
            break
        case 8:
            title.text = "设备描述"
            content.text = model.deviceComment ?? "暂无内容"
            
            break
            
        default:
            break
        }
        
        
    }
    
    override func initViews() {
        
        self.backgroundColor = Constant.bgViewColor
        addSubview(bgView)

        addSubview(sepView)
        bgView.addSubview(title)
        bgView.addSubview(content)
        bgView.addSubview(lineView)
      
        sepView.snp.makeConstraints { (make) in
            make.left.right.equalToSuperview()
            make.height.equalTo(10.autoWidth())
            make.top.equalToSuperview()
        }
        bgView.snp.makeConstraints { (make) in
            
            make.left.equalToSuperview().offset(15.autoWidth())
            make.right.equalToSuperview().offset(-15.autoWidth())
            make.bottom.equalToSuperview().offset(0)
            make.top.equalTo(sepView.snp.bottom).offset(0)
        }
        title.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(autoWidth(23))
            make.left.equalToSuperview().offset(autoWidth(10))
            make.right.equalToSuperview().offset(autoWidth(-10.0))
            make.height.equalTo(14.autoWidth())
        }
        
        content.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(autoWidth(65))
            make.left.equalToSuperview().offset(autoWidth(10))
            make.right.equalToSuperview().offset(autoWidth(-10.0))
            make.height.greaterThanOrEqualTo(15.autoWidth())
            make.bottom.equalToSuperview().offset(-15.autoWidth())
        }
        
        lineView.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(autoWidth(50))
            make.left.equalToSuperview()
            make.right.equalToSuperview()
            make.height.equalTo(0.5.autoWidth())
        }
    }
}
